((* extends "sbp_messages_table.tex" *))
((* block messages_desc *))
\newpage
\section{Stable Message Definitions}
((*- for m in msgs *))
((*- if m.pkg *))
\subsection{(((m.pkg|packagenameify|header_write|no_us)))}
\begin{large}
(((m.pkg_desc | escape_tex )))
\end{large}
((* endif *))

\subsubsection{(((m.name | escape_tex ))) ((*- if m.is_real_message *)) --- ((('0x%04X'|format(m.sbp_id)))) --- (((m.sbp_id))) ((*- endif -*))}
\label{sec:(((m.name)))}

\begin{large}
(((m.desc|escape_tex)))
\end{large}

\vspace{3em}
\begin{table}[H]
  \centering
  \rowcolors{2}{gray!20}{white}
  \begin{tabularx}{\textwidth}{bZacNX}
    \toprule
    \hiderowcolors
    Offset (bytes) & Size (bytes) & Format & Units & Name & Description \\
    \midrule
    \showrowcolors
    ((*- for f in m.fields *))
      $\mathtt{(((f.offset)))}$ &
      $\mathtt{(((f.size)))}$ &
      (((f.fmt))) &
      (((f.units|escape_tex))) &
      \texttt{(((f.name|escape_table_name)))} &
      ((*- if f.is_gnss_signal *))
      \hangindent=0.5em{(((f.desc|append_signals_table)))} \\
      ((*- else *))
      \hangindent=0.5em{(((f.desc|escape_tex)))} \\
      ((*- endif *))
      ((*- endfor *))
    \midrule
    \hiderowcolors
    & $\mathtt{(((m.size)))}$ & & & & Total Payload Length\\
    \bottomrule
  \end{tabularx}
  \caption{(((m.name|escape_tex))) 
  ((*- if m.is_real_message *)) (((('0x%04X'|format(m.sbp_id))))) 
  ((*- endif *))
  message structure}
  \label{tab:(((m.name)))}
\end{table}

((*- for f in m.fields *))
((*- if f.is_gnss_signal *))

((*- else *))
((*- if f.bitfields *))
\begin{table}[H]
  \centering
  ((*- if f.n_with_values == 1 *))
  \begin{minipage}[b][][b]{.48\textwidth}
  ((*- else *))
  \begin{minipage}[c][][c]{.48\textwidth}
  ((*- endif *))
  \centering
  ((*- for bf in f.bitfields *))
  \regfieldb{(((bf['desc'])))((* if 'vals' in bf *)) (\autoref{tab:(((m.name)))_(((f.name|nobrackets)))(((bf['range'])))})((* endif *))}{(((bf['len'])))}{(((bf['lsb'])))}
  ((*- endfor *))
  \captionof{field}{(((f.desc))) (\texttt{(((f.name|removearray|escape_tex)))})}
  \label{fld:(((m.name)))_(((f.name|nobrackets)))}
  \end{minipage}
  \hfill
  ((*- if f.n_with_values == 1 *))
  \begin{minipage}[b][][b]{.48\textwidth}
  ((*- else *))
  \begin{minipage}[c][][c]{.48\textwidth}
  ((*- endif *))
  \centering
  ((*- for bf in f.bitfields|reverse if 'vals' in bf *))
    \begin{tabular}{ll}
      \toprule
      Value & Description \\
      \midrule
      ((*- for v in bf['vals'] *))
      (((v['value']))) & (((v['desc']|escape_tex))) \\
      ((*- endfor *))
      \bottomrule
    \end{tabular}
    \caption{(((bf['desc']))) values (\texttt{(((f.name|removearray|escape_tex)))[(((bf['range'])))]})}
    \label{tab:(((m.name)))_(((f.name|nobrackets)))(((bf['range'])))}

  ((*- if not loop.last *))
  \vspace{2em}
  ((*- endif *))
  ((*- endfor *))
  \end{minipage}
\end{table}
((*- endif *))
((*- endif *))
((*- endfor *))
\newpage
((*- endfor *))
\section{Draft Message Definitions}
((*- for m in umsgs *))
((*- if m.pkg *))
\subsection{(((m.pkg|packagenameify|no_us|header_write)))}

\begin{large}
(((m.pkg_desc)))
\end{large}
((* endif *))
\subsubsection*{(((m.name|escape_tex|no_us))) --- ((('0x%04X'|format(m.sbp_id)))) --- (((m.sbp_id)))}
\label{sec:(((m.name)))}
\begin{minipage}{\textwidth}
\begin{large}
(((m.desc|escape_tex)))
\end{large}
\end{minipage}
\vspace{3em}
\begin{table}[h]
  \centering
  \rowcolors{2}{gray!20}{white}
  \begin{tabularx}{\textwidth}{cZacNX}
    \toprule
    \hiderowcolors
    Offset (bytes) & Size (bytes) & Format & Units & Name & Description \\
    \showrowcolors
    \midrule
    ((*- for f in m.fields *))
      $\mathtt{(((f.offset)))}$ &
      $\mathtt{(((f.size)))}$ &
      (((f.fmt))) &
      (((f.units|escape_tex))) &
      \texttt{(((f.name|escape_table_name)))} &
      \hangindent=0.5em{(((f.desc|escape_tex)))} \\
      ((*- endfor *))
    \midrule
    \hiderowcolors
    & $\mathtt{(((m.size)))}$ & & & & Total Payload Length\\
    \bottomrule
  \end{tabularx}
  \caption{(((m.name|escape_tex))) (((('0x%04X'|format(m.sbp_id))))) message structure}
  \label{tab:(((m.name)))}
\end{table}

((*- for f in m.fields *))
((*- if f.bitfields *))
\begin{table}[H]
  \centering
  ((*- if f.n_with_values == 1 *))
  \begin{minipage}[b][][b]{.48\textwidth}
  ((*- else *))
  \begin{minipage}[c][][c]{.48\textwidth}
  ((*- endif *))
  \centering
  ((*- for bf in f.bitfields *))
  \regfieldb{(((bf['desc'])))((* if 'vals' in bf *)) (\autoref{tab:(((m.name)))_(((f.name|nobrackets)))(((bf['range'])))})((* endif *))}{(((bf['len'])))}{(((bf['lsb'])))}
  ((*- endfor *))
  \captionof{field}{(((f.desc))) (\texttt{(((f.name|removearray|escape_tex)))})}
  \label{fld:(((m.name)))_(((f.name|nobrackets)))}
  \end{minipage}
  \hfill
  ((*- if f.n_with_values == 1 *))
  \begin{minipage}[b][][b]{.48\textwidth}
  ((*- else *))
  \begin{minipage}[c][][c]{.48\textwidth}
  ((*- endif *))
  \centering
  ((*- for bf in f.bitfields|reverse if 'vals' in bf *))
    \begin{tabular}{ll}
      \toprule
      Value & Description \\
      \midrule
      ((*- for v in bf['vals'] *))
      (((v['value']))) & (((v['desc']|escape_tex))) \\
      ((*- endfor *))
      \bottomrule
    \end{tabular}
    \caption{(((bf['desc']))) values (\texttt{(((f.name|removearray|escape_tex)))[(((bf['range'])))]})}
    \label{tab:(((m.name)))_(((f.name|nobrackets)))(((bf['range'])))}

  ((*- if not loop.last *))
  \vspace{2em}
  ((*- endif *))
  ((*- endfor *))
  \end{minipage}
\end{table}
((*- endif *))
((*- endfor *))
\clearpage

\newpage
((*- endfor *))
((* endblock *))
